Socket
Socket
Sign inDemoInstall

ember-template-lint

Package Overview
Dependencies
101
Maintainers
7
Versions
215
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ember-template-lint

Linter for Ember or Handlebars templates.


Version published
Maintainers
7
Install size
9.25 MB
Created

Changelog

Source

v2.21.0 (2021-02-26)

:rocket: Enhancement
  • #1787 New rule: no-link-to-positional-params (@scalvert)
:bug: Bug Fix
Committers: 2

Readme

Source

ember-template-lint

npm version Build Status

ember-template-lint will lint your handlebars template and return error results.

For example, given the rule no-bare-strings is enabled, this template would be in violation:

{{!-- app/components/my-thing/template.hbs  --}}
<div>A bare string</div>

When the ember-template-lint executable is run, we would have a single result indicating that the no-bare-strings rule found an error.

Installation

This addon is installed by default with new Ember apps, so check your package.json before installing to see if you need to install it.

To install ember-template-lint

With npm:

npm install --save-dev ember-template-lint

With yarn:

yarn add ember-template-lint --dev

Node.js 10 || >=12 is required.

Usage

While ember-template-lint does have a Node API, the main way to use it is through its executable, which is intended to be installed locally within a project.

Basic usage is as straightforward as

ember-template-lint .

Workflow Examples

Basic usage with a single file

ember-template-lint "app/templates/application.hbs"

Output errors with source description

ember-template-lint "app/templates/application.hbs" --verbose

Multiple file/directory/wildcard paths are accepted

ember-template-lint "app/templates/components/**/*" "app/templates/application.hbs"

Output errors as pretty-printed JSON string

ember-template-lint "app/templates/application.hbs" --json

Ignore warnings / only report errors

ember-template-lint "app/templates/application.hbs" --quiet

Number of warnings to trigger nonzero exit code

ember-template-lint "app/templates/application.hbs" --max-warnings=2

Define custom config path

ember-template-lint "app/templates/application.hbs" --config-path .my-template-lintrc.js

Read from stdin

ember-template-lint --filename app/templates/application.hbs < app/templates/application.hbs

Print list of formatted rules for use with pending in config file

ember-template-lint "app/templates/application.hbs" --print-pending

Specify custom ignore pattern ['**/dist/**', '**/tmp/**', '**/node_modules/**'] by default

ember-template-lint "/tmp/template.hbs" --ignore-pattern "**/foo/**" --ignore-pattern "**/bar/**"

Disable ignore pattern entirely

ember-template-lint "/tmp/template.hbs" --no-ignore-pattern

Running a single rule without options

ember-template-lint --no-config-path app/templates --rule 'no-implicit-this:error'

Running a single rule with options

ember-template-lint --no-config-path app/templates --rule 'no-implicit-this:["error", { "allow": ["some-helper"] }]'

Running a single rule, disabling inline configuration

ember-template-lint --no-config-path app/templates --rule 'no-implicit-this:error' --no-inline-config

Specify a config object to use instead of what exists locally

ember-template-lint --config '{ "rules": { "no-implicit-this": { "severity": 2, "config": true } } }' test/fixtures/no-implicit-this-allow-with-regexp/app/templates

:bulb: Ensure you wrap all glob patterns in quotes so that it won't be interpreted by the CLI. ember-template-lint app/templates/** (this will expand all paths in app/templates) and ember-template-lint "app/templates/**" (this will pass the glob to ember-template-lint and not interpret the glob).

Configuration

Project Wide

You can turn on specific rules by toggling them in a .template-lintrc.js file at the base of your project, or at a custom relative path which may be identified using the CLI:

module.exports = {
  extends: 'recommended',

  rules: {
    'no-bare-strings': true,
  },
};

For more detailed information see configuration.

Presets

NameDescription
:white_check_mark:recommendedenables the recommended rules
:car:octaneextends the recommended preset by enabling Ember Octane rules
:nail_care:stylisticenables stylistic rules for those who aren't ready to adopt ember-template-lint-plugin-prettier (including stylistic rules that were previously in the recommended preset in ember-template-lint v1)

Rules

Each rule has emojis denoting:

  • what configuration it belongs to
  • :wrench: if some problems reported by the rule are automatically fixable by the --fix command line option
Rule ID
attribute-indentation
:nail_care:block-indentation
builtin-component-arguments
deprecated-each-syntax
deprecated-inline-view-helper
:white_check_mark:deprecated-render-helper
:nail_care:eol-last
:wrench:inline-link-to
:nail_care:linebreak-style
:white_check_mark:link-href-attributes
:white_check_mark::wrench:link-rel-noopener
modifier-name-case
:white_check_mark:no-abstract-roles
:wrench:no-accesskey-attribute
:car:no-action
no-action-modifiers
:white_check_mark:no-args-paths
no-arguments-for-html-elements
:wrench:no-aria-hidden-body
:white_check_mark:no-attrs-in-components
no-bare-strings
no-block-params-for-html-elements
no-capital-arguments
no-class-bindings
:car::wrench:no-curly-component-invocation
:white_check_mark:no-debugger
no-down-event-binding
:white_check_mark:no-duplicate-attributes
no-duplicate-id
no-duplicate-landmark-elements
no-dynamic-subexpression-invocations
no-element-event-actions
:white_check_mark:no-extra-mut-helper-argument
no-forbidden-elements
no-heading-inside-button
:white_check_mark:no-html-comments
:car:no-implicit-this
:white_check_mark:no-index-component-invocation
:white_check_mark:no-inline-styles
:white_check_mark:no-input-block
:white_check_mark:no-input-tagname
no-invalid-block-param-definition
:white_check_mark:no-invalid-interactive
:white_check_mark:no-invalid-link-text
no-invalid-link-title
:white_check_mark:no-invalid-meta
:white_check_mark:no-invalid-role
no-link-to-positional-params
no-link-to-tagname
:white_check_mark:no-log
:wrench:no-model-argument-in-route-templates
:nail_care:no-multiple-empty-lines
no-mut-helper
:white_check_mark:no-negated-condition
:white_check_mark:no-nested-interactive
no-nested-landmark
no-nested-splattributes
:white_check_mark:no-obsolete-elements
:white_check_mark:no-outlet-outside-routes
:white_check_mark:no-partial
no-passed-in-event-handlers
:wrench:no-positional-data-test-selectors
:white_check_mark:no-positive-tabindex
no-potential-path-strings
:white_check_mark:no-quoteless-attributes
:wrench:no-redundant-fn
:wrench:no-redundant-landmark-role
no-restricted-invocations
:white_check_mark:no-shadowed-elements
:wrench:no-this-in-template-only-components
:nail_care:no-trailing-spaces
:white_check_mark:no-triple-curlies
no-unbalanced-curlies
:white_check_mark:no-unbound
no-unknown-arguments-for-builtin-components
:white_check_mark:no-unnecessary-component-helper
:nail_care:no-unnecessary-concat
:white_check_mark:no-unused-block-params
no-whitespace-for-layout
no-whitespace-within-word
no-yield-only
no-yield-to-default
:nail_care:quotes
:white_check_mark::wrench:require-button-type
require-each-key
require-form-method
:wrench:require-has-block-helper
:white_check_mark:require-iframe-title
require-input-label
require-lang-attribute
require-splattributes
:white_check_mark:require-valid-alt-text
:nail_care:self-closing-void-elements
:white_check_mark:simple-unless
splat-attributes-only
:white_check_mark:style-concatenation
:white_check_mark:table-groups
template-length

Supporting the --fix option

You can add a fixer to a rule. See fixer documentation for more details.

Sharing configs

It is possible to share a config (extends) or plugin (custom rules) across projects. See ember-template-lint-plugin-peopleconnect for an example.

Defining your own rules

You can define and use your own custom rules using the plugin system. See plugin documentation for more details.

Semantic Versioning Policy

The semver policy for this addon can be read here: semver policy.

Contributing

See the Contributing Guidelines for information on how to help out.

License

This project is licensed under the MIT License.

FAQs

Last updated on 26 Feb 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc